import VNode from "./index.js"

/**
 * 创建VNode
 * @namespace
 * @param {*} nodeType 
 * @param {*} data 
 * @param {*} text 
 * @param {*} ele 
 * @param {*} children 
 * @returns VNode
 */
const createVNode = (nodeType, data, text, ele, children) => {
  const node = new VNode(nodeType, data, text, ele, children)
  return node
}

/**
 * 创建真实元素节点
 * @namespace
 * @param {*} tagName 
 * @param {*} data 
 * @returns Node
 */
const createElement = (tagName, data) => {
  const node = document.createElement(tagName, data)
  return node
}

/**
 * 创建真实属性节点
 * @param {*} attr 
 * @param {*} value 
 * @returns node
 */
const createAttribute = (attr, value) => {
  const node = document.createAttribute(attr)
  node.value = value
  return node
}

/**
 * 创建真实注释节点
 * @param {*} value 
 * @returns node
 */
const createComment = (value) => {
  const node = document.createComment(value)
  return node
}

/**
 * 创建真实文档片段
 * @returns node
 */
const createDocumentFragment = () => {
  const node = document.createDocumentFragment()
  return node
}

/**
 * 创建真实文本节点
 * @param {*} value 
 * @returns node
 */
const createTextNode = (value) => {
  const node = document.createTextNode(value)
  return node
}

export {
  createVNode,
  createElement,
  createAttribute,
  createComment,
  createDocumentFragment,
  createTextNode
}